package lt.ntec.danblog.server.blog.model.objectify;

import com.googlecode.objectify.Key;
import java.util.Date;
import javax.jdo.annotations.PersistenceCapable;

import javax.persistence.Id;
import javax.persistence.Transient;
import lt.ntec.danblog.server.core.model.Comment;
import lt.ntec.danblog.server.core.model.Commentable;
import lt.ntec.danblog.server.core.model.User;

@PersistenceCapable
class BlogComment implements Comment {

    @Id
    private Long id;
    private Key<User> userKey;
    @Transient
    private User user;
    private Key<Commentable> parentKey;
    @Transient
    private Commentable parent;
    private String content;
    private Date date;
    private int voteDown;
    private int voteUp;

    @Override
    public User getUser() {
        return user;
    }

    @Override
    public String getContent() {
        return content;
    }

    @Override
    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public Date getDate() {
        return date;
    }

    @Override
    public void setDate(Date date) {
        this.date = date;
    }

    @Override
    public Commentable getParent() {
        return parent;
    }

    @Override
    public int getVoteUp() {
        return voteUp;
    }

    @Override
    public int getVoteDown() {
        return voteDown;
    }

    @Override
    public void addVoteDown() {
        voteDown++;
    }

    @Override
    public void addVoteUp() {
        voteUp++;
    }

    @Override
    public boolean hasUserVoted(User user) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public Long getId() {
        return id;
    }
}
